/*
 * Powered By [pkuWx]
 * Web Site: http://www.wuxi.ss.pku.edu.cn
 * Since 2015 - 2015
 */

package cn.edu.pku.wxlib.adminuser.model;

import javax.validation.constraints.*;

import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import cn.org.rapid_framework.util.DateConvertUtils;

import java.util.*;

import cn.edu.pku.wxlib.adminuser.model.*;
import cn.edu.pku.wxlib.adminuser.service.*;
import cn.edu.pku.wxlib.adminuser.vo.query.*;
import cn.edu.pku.wxlib.role.model.*;
import javacommon.base.*;
import javacommon.util.*;
import javacommon.page.Page;

/**
 * @version 1.0
 * @since 1.0
 */


public class Adminuser extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Adminuser";
	public static final String ALIAS_ADMIN_ID = "管理员主键";
	public static final String ALIAS_ADMIN_NAME = "用户名";
	public static final String ALIAS_PASSWORD = "密码";
	public static final String ALIAS_NAME = "姓名";
	public static final String ALIAS_BIRTH = "出生年月";
	public static final String ALIAS_GENDER = "性别";
	public static final String ALIAS_TEL = "座机";
	public static final String ALIAS_PHONE = "手机";
	public static final String ALIAS_EMAIL = "邮箱";
	public static final String ALIAS_CREATE_TIME = "创建时间";
	public static final String ALIAS_STATE = "状态（1启用，0禁用）";
	
	//date formats
	public static final String FORMAT_BIRTH = DATE_FORMAT;
	public static final String FORMAT_CREATE_TIME = DATE_FORMAT;
	
	//columns START
    /** 管理员主键       db_column: adminId */	
	
	private java.lang.Integer adminId;
    /** 用户名       db_column: adminName */	
	@NotBlank @Length(max=10)
	private java.lang.String adminName;
    /** 密码       db_column: password */	
	@NotBlank @Length(max=32)
	private java.lang.String password;
    /** 姓名       db_column: name */	
	@Length(max=32)
	private java.lang.String name;
    /** 出生年月       db_column: birth */	
	
	private java.util.Date birth;
    /** 性别       db_column: gender */	
	
	private java.lang.Integer gender;
    /** 座机       db_column: tel */	
	@Length(max=12)
	private java.lang.String tel;
    /** 手机       db_column: phone */	
	@Length(max=11)
	private java.lang.String phone;
    /** 邮箱       db_column: email */	
	@Email @Length(max=64)
	private java.lang.String email;
    /** 创建时间       db_column: createTime */	
	
	private java.util.Date createTime;
    /** 状态（1启用，0禁用）       db_column: state */	
	
	private java.lang.Integer state;
	//columns END
	//额外属性
	private List<Role> rolelist;
	
	public Adminuser(){
	}

	public Adminuser(
		java.lang.Integer adminId
	){
		this.adminId = adminId;
	}

	public void setAdminId(java.lang.Integer value) {
		this.adminId = value;
	}
	
	public java.lang.Integer getAdminId() {
		return this.adminId;
	}
	public void setAdminName(java.lang.String value) {
		this.adminName = value;
	}
	
	public java.lang.String getAdminName() {
		return this.adminName;
	}
	public void setPassword(java.lang.String value) {
		this.password = value;
	}
	
	public java.lang.String getPassword() {
		return this.password;
	}
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	public java.lang.String getName() {
		return this.name;
	}
	public String getBirthString() {
		return DateConvertUtils.format(getBirth(), FORMAT_BIRTH);
	}
	public void setBirthString(String value) {
		setBirth(DateConvertUtils.parse(value, FORMAT_BIRTH,java.util.Date.class));
	}
	
	public void setBirth(java.util.Date value) {
		this.birth = value;
	}
	
	public java.util.Date getBirth() {
		return this.birth;
	}
	public void setGender(java.lang.Integer value) {
		this.gender = value;
	}
	
	public java.lang.Integer getGender() {
		return this.gender;
	}
	public void setTel(java.lang.String value) {
		this.tel = value;
	}
	
	public java.lang.String getTel() {
		return this.tel;
	}
	public void setPhone(java.lang.String value) {
		this.phone = value;
	}
	
	public java.lang.String getPhone() {
		return this.phone;
	}
	public void setEmail(java.lang.String value) {
		this.email = value;
	}
	
	public java.lang.String getEmail() {
		return this.email;
	}
	public String getCreateTimeString() {
		return DateConvertUtils.format(getCreateTime(), FORMAT_CREATE_TIME);
	}
	public void setCreateTimeString(String value) {
		setCreateTime(DateConvertUtils.parse(value, FORMAT_CREATE_TIME,java.util.Date.class));
	}
	
	public void setCreateTime(java.util.Date value) {
		this.createTime = value;
	}
	
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	public void setState(java.lang.Integer value) {
		this.state = value;
	}
	
	public java.lang.Integer getState() {
		return this.state;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("AdminId",getAdminId())
			.append("AdminName",getAdminName())
			.append("Password",getPassword())
			.append("Name",getName())
			.append("Birth",getBirth())
			.append("Gender",getGender())
			.append("Tel",getTel())
			.append("Phone",getPhone())
			.append("Email",getEmail())
			.append("CreateTime",getCreateTime())
			.append("State",getState())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getAdminId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Adminuser == false) return false;
		if(this == obj) return true;
		Adminuser other = (Adminuser)obj;
		return new EqualsBuilder()
			.append(getAdminId(),other.getAdminId())
			.isEquals();
	}

	public List<Role> getRolelist() {
		return rolelist;
	}

	public void setRolelist(List<Role> rolelist) {
		this.rolelist = rolelist;
	}
	
	public String getRoles(){
		StringBuffer rolessb = new StringBuffer();
        for (Role role : rolelist) {
            rolessb.append(role.getRoleName() + ",");
        }
        int i = rolessb.lastIndexOf(",");
        return i > 0 ? rolessb.substring(0, i) : "";
	}
}

